<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>给出一个使用 PostScript Type1 字体的文本方框</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.imagepsbbox" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagepsbbox</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">imagepsbbox</span> &mdash; <span class="dc-title">给出一个使用 PostScript Type1 字体的文本方框</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagepsbbox-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagepsbbox</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$text</code></span>
   , <span class="methodparam"><span class="type">resource</span> <code class="parameter">$font</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$size</code></span>
   ) : <span class="type">array</span></div>

  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagepsbbox</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$text</code></span>
   , <span class="methodparam"><span class="type">resource</span> <code class="parameter">$font</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$size</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$space</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$tightness</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$angle</code></span>
   ) : <span class="type">array</span></div>

  <p class="para rdfs-comment">
   给出一个使用 PostScript Type1 字体的文本方框。
  </p>
  <p class="para">
   围绕文本范围的虚拟方框是用从字符度量学中的可用信息来计算的，不幸的是往往和实际上光栅生成的文本的结果有少许不同。如果角度为
   0 度，（根据经验）文本在每个方向上都需要多 1 个像素。
  </p>
  
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagepsbbox-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">text</code></dt>

     <dd>

      <p class="para">
       要写入的文本。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">font_index</code></dt>

     <dd>

      <p class="para"> <span class="function"><a href="imagepsloadfont.html" class="function">imagepsloadfont()</a></span> 所返回的字体资源。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">size</code></dt>

     <dd>

      <p class="para">
       <code class="parameter">size</code> 以像素表示。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">space</code></dt>

     <dd>

      <p class="para">
       可以用来改变字体中默认间距的值。此值将被加到通常的值上，可以为负值。
       以字符间距单元表示，1 个单元为 1 em-square 的一千分之一。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">tightness</code></dt>

     <dd>

      <p class="para">
       <code class="parameter">tightness</code> 
       可以控制字符之间的间距。此值将被加到通常字符宽度上，可以为负值。
       以字符间距单元表示，1 个单元为 1 em-square 的一千分之一。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">angle</code></dt>

     <dd>

      <p class="para">
       <code class="parameter">angle</code> 以角度表示。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagepsbbox-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   本函数返回包含有下列单元的数组：
   <table class="doctable informaltable">
    
     <tbody class="tbody">
      <tr>
       <td>0</td>
       <td>左下角的 X 坐标</td>
      </tr>

      <tr>
       <td>1</td>
       <td>左下角的 Y 坐标</td>
      </tr>

      <tr>
       <td>2</td>
       <td>右上角的 X 坐标</td>
      </tr>

      <tr>
       <td>3</td>
       <td>右上角的 Y 坐标</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.imagepsbbox-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-3726">
   <p><strong>Example #1 <span class="function"><strong>imagepsbbox()</strong></span> 用法</strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;创建图像的句柄<br /></span><span style="color: #0000BB">$im&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreatetruecolor</span><span style="color: #007700">(</span><span style="color: #0000BB">200</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">200</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;分配颜色<br /></span><span style="color: #0000BB">$black&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$white&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">255</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">255</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">255</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;载入&nbsp;PostScript&nbsp;字体<br /></span><span style="color: #0000BB">$font&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagepsloadfont</span><span style="color: #007700">(</span><span style="color: #DD0000">'font.pfm'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;设置文本方框<br /></span><span style="color: #0000BB">$bbox&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagepsbbox</span><span style="color: #007700">(</span><span style="color: #DD0000">'Sample&nbsp;text&nbsp;is&nbsp;simple'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$font</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">12</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;定义&nbsp;X&nbsp;和&nbsp;Y&nbsp;<br /></span><span style="color: #0000BB">$x&nbsp;</span><span style="color: #007700">=&nbsp;(</span><span style="color: #0000BB">$bbox</span><span style="color: #007700">[</span><span style="color: #0000BB">2</span><span style="color: #007700">]&nbsp;/&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">)&nbsp;-&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$y&nbsp;</span><span style="color: #007700">=&nbsp;(</span><span style="color: #0000BB">$bbox</span><span style="color: #007700">[</span><span style="color: #0000BB">3</span><span style="color: #007700">]&nbsp;/&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">)&nbsp;-&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;字体写入图像<br /></span><span style="color: #0000BB">imagepstext</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Sample&nbsp;text&nbsp;is&nbsp;simple'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$font</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">12</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$black</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$white</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$x</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$y</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;输出并释放内存<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type:&nbsp;image/png'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
   </div>

  </div>
 </div>

 <div class="refsect1 notes" id="refsect1-function.imagepsbbox-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">此函数仅在 PHP
编译时指定了 <strong class="option configure">--with-t1lib[=DIR]</strong>
 时可用。</span></p></blockquote>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.imagepsbbox-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="imagepstext.html" class="function" rel="rdfs-seeAlso">imagepstext()</a> - 用 PostScript Type1 字体把文本字符串画在图像上</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>